package com.bzy.controller;

import com.bzy.Book;
import com.bzy.BookInfo;
import com.bzy.DataPage;
import com.bzy.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

/**
 * @ Author     : Bzy.
 * @ Date       : 2020/12/28 -- 20:10
 * @ Version:     $ 1.0
 */
@Controller
public class BookController {
    @Autowired
    private BookService bookService;

    @RequestMapping("/get_books")
    public String getAllBook(Integer page, Model model) {
        Integer pageNum = page == null ? 1 : page;

        DataPage<Book> book = bookService.getAllBook(pageNum);

        model.addAttribute("bookPage", book);
        return "all_books";
    }
}
